package com.saltlux.storm.study.bbs;

import java.util.Map;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

public class ArticleDTO implements DTO {
	
	private String id;
	private String boardId;
	private String subject;
	private String content;
	private String createdAt;
	private String createdBy;
	private String lastModifiedAt;
	private String lastModifiedBy;
	private String hits;
	
	public ArticleDTO() {
		super();
	}

	public static ArticleDTO valueOf(Map<String, String> map) {
		ArticleDTO article = new ArticleDTO();
		article.setId(map.get("ID"));
		article.setBoardId(map.get("BOARDID"));
		article.setContent(map.get("CONTENT"));
		article.setSubject(map.get("SUBJECT"));
		article.setCreatedAt(map.get("CREATEDAT"));
		article.setCreatedBy(map.get("CREATEDBY"));
		article.setLastModifiedAt(map.get("LASTMODIFIEDAT"));
		article.setLastModifiedBy(map.get("LASTMODIFIEDBY"));
		article.setHits(map.get("HITS"));
		return article;
	}
	
	public ArticleDTO(String id, String subject, String content,
			String createdAt, String createdBy, String lastModifiedAt,
			String lastModifiedBy, String hits) {
		super();
		this.id = id;
		this.subject = subject;
		this.content = content;
		this.createdAt = createdAt;
		this.createdBy = createdBy;
		this.lastModifiedAt = lastModifiedAt;
		this.lastModifiedBy = lastModifiedBy;
		this.hits = hits;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setBoardId(String boardId) {
		this.boardId = boardId;
	}
	
	public String getBoardId() {
		return this.boardId;
	}
	
	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(String createdAt) {
		this.createdAt = createdAt;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getLastModifiedAt() {
		return lastModifiedAt;
	}

	public void setLastModifiedAt(String lastModifiedAt) {
		this.lastModifiedAt = lastModifiedAt;
	}

	public String getLastModifiedBy() {
		return lastModifiedBy;
	}

	public void setLastModifiedBy(String lastModifiedBy) {
		this.lastModifiedBy = lastModifiedBy;
	}

	public String getHits() {
		return hits;
	}

	public void setHits(String hits) {
		this.hits = hits;
	}
	
	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}

	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
